aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/(app)/fund/[id]/access/+page.server.ts
blob: 36191643678d30ae7133d2d675f1127b83d9cd42 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { auth, fd, get, post } from "$lib/utils";
import { fail } from "@sveltejs/kit";

export const load = async ({ params: { id } }) => {
	const managers = await get(`/fund/${id}/managers`);
	return { managers, id };
};

export const actions = {
	default: async ({ cookies, request }) => {
		const form = await fd(request);

		try {
			const managers = await post("/fund/managers", form, auth(cookies));

			return { managers };
		} catch (e) {
			const { message } = e as Error;
			return fail(400, { message });
		}
	},
};